#include <iostream>
#include <stdio.h>
#include <stdlib.h> 
using namespace std;


int paixu(int array[],int length){
	for (int i = 0;i<length;i++){
		bool flag = false;
		for (int j =0;j<=length-i-1;j++){
			if (array[j]<array[j-1]){
				int temp = array[j];
				array[j] = array[j-1];
				array[j-1] = temp;
				flag = true;
			}
		}
		if (!flag){
			break;
		}
	}
}



int main(){
	int array[] = {14,5,1,3,98,77,54,64,10};
	int length = sizeof(array)/sizeof(array[0]);
	cout <<"排序前: ";
	for (int i = 0;i<length;i++){
		printf("%2d ",array[i]);
	}
	cout << endl;
	paixu(array,length);
    cout <<"排序后: ";
	for (int i = 0;i<length;i++){
		printf("%2d ",array[i]);
	}
//	system("pause");
	cout << endl;
}